package fun.xinnix.handle;

import cn.hutool.http.HttpStatus;
import fun.xinnix.commons.Result;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.RestControllerAdvice;

@RestControllerAdvice
public class GlobalException {
    @ExceptionHandler(Exception.class)
    public ResponseEntity<?> exception(Exception e) {
        e.printStackTrace();
        Result result = new Result();
        result.setCode(HttpStatus.HTTP_INTERNAL_ERROR);
        result.setMsg(e.getMessage());
        return ResponseEntity.badRequest().body(result);
    }
}
